<template>
  <div>
    <a-card :bordered="false">
      <f-search-form :more="false" @searchHandler="searchHandler">
        <f-search-form-item label="发票抬头" name="invoiceTitle"/>
      </f-search-form>
      <f-table ref="table" size="default" rowKey="invoiceId" :columns="columns" :multiple="false" handler="shopInvoiceListHandler" :operator="operator" :params="queryParam" :api="api.invoice" order="createTime">
        <span slot="invoiceType" slot-scope="text, record, index">
         <span v-if="record.invoiceType==1">个人发票</span>
         <span v-if="record.invoiceType==2">企业发票</span>
        </span>
        <span slot="invoiceState" slot-scope="text, record, index">
            <a-tag color="pink" v-if="text==0">未开</a-tag>
            <a-tag color="#108ee9" v-if="text==1">已开</a-tag>
        </span>
        <span slot="action" slot-scope="text, record">
          <template>
            <a @click="$refs.modal.handleShow(record)">编辑</a>
            <a-divider type="vertical"/>
          </template>
          <a-dropdown>
            <a class="ant-dropdown-link">
              更多 <a-icon type="down"/>
            </a>
            <a-menu slot="overlay">
              <a-menu-item v-if="$auth('table.delete')">
                <a href="javascript:;" @click="$refs.table.remove(record.invoiceId)">删除</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </f-table>
      <order-invoice-drawer ref="modal"></order-invoice-drawer>
    </a-card>
  </div>
</template>

<script>
  import OrderInvoiceDrawer from './invoice_drawer'

  export default {
    name: 'TableList',
    components: {
      OrderInvoiceDrawer
    },
    data() {
      let me = this
      return {
        //列表初始化查询参数
        queryParam: {
          invoiceTitle: ''
        },
        // 表头
        columns: [
          {
            title: '发票抬头',
            dataIndex: 'invoiceTitle',
            align: 'center'
          },
          {
            title: '发票类型',
            dataIndex: 'invoiceType',
            align: 'center',
            scopedSlots: { customRender: 'invoiceType' }
          },
          {
            title: '发票金额',
            dataIndex: 'invoiceAmount',
            align: 'center'
          },
          {
            title: '单号',
            dataIndex: 'orderNo',
            align: 'center'
          },
          {
            title: '开票状态',
            align: 'center',
            dataIndex: 'invoiceState',
            scopedSlots: { customRender: 'invoiceState' }
          },
          {
            title: '备注',
            dataIndex: 'remark',
            align: 'center'
          },
          {
            title: '操作',
            dataIndex: 'action',
            scopedSlots: { customRender: 'action' }
          }
        ],
        //操作按钮
        operator: [
          {
            name: '删除',
            icon: 'delete',
            batch: true,
            handler: function(table) {
              table.remove()
            }
          }
        ]
      }
    },
    created() {

    },
    methods: {}

  }
</script>
